package no.hio.wsclient;



import java.util.List;

import junit.framework.TestCase;
import no.hio.wsproviderstock.StockItem;
import no.hio.wsproviderstock.StockItemService;
import no.hio.wsproviderstock.StockItemServiceImplService;

import org.junit.Before;
import org.junit.Test;

/**
 * Tests if StockItem web-service is available
 * @author Henning Gundersen
 */
public class StockItemServiceTestCase extends TestCase
{
	StockItemService stockItemService;
	@Before
	public void setUp() throws Exception
	{
		StockItemServiceImplService  stockImpl = new StockItemServiceImplService();
		stockItemService = (StockItemService) stockImpl.getStockItemServicePort();
	}
	
	@Test
	public void testFindAllProducts()
	{
		List<StockItem> stockItemList;
		stockItemList = stockItemService.findAllStockItems();
		stockItemList = null;
	}
	
	@Test
	public void testFindByProductID()
	{
		List<StockItem> stockItemList = stockItemService.findAllStockItems();
		StockItem p = stockItemList.get(0);
		StockItem n = stockItemService.findByProductID(p.getProductID());
		assertEquals(p.getProductID(), n.getProductID());
		n = p = null;
		stockItemList = null;
	}
}
